package com.mycat.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 *	RMI 客户端
 *	1. RMI 请求路径、2. RMI 接口（一定不需要 RMI 实现类，否则就是本地调用了）
 * @author Roger
 */
public class RmiClient {

	public static void main(String[] args) {

		String url = "rmi://localhost:1099/com.mycat.rmi.HelloServiceImpl";
		HelloService helloService;
		try {
			helloService = (HelloService) Naming.lookup(url);
			String result = helloService.sayHello("Jack");
			System.out.println(result);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
		
	}

}
